/******************************************************************
 * Created by: GOh CHee Hong                                      
 * Date of Creation: 1/Jan/2009            
 
 *                                                                
 * Description: This class is in charge of preparing RSS feeds
 ******************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using Rss;
using System.Collections;
namespace Pbdms.BusinessLogic.RSSProcessor
{
    public class RssProcessor
    {
       
      
        public RssProcessor()
        {
           
        }
        /// <summary>
        /// prepare feeds
        /// </summary>
        /// <returns></returns>
        public Rss.RssChannel getsFeed()
        {

            RssFeed feed = new RssFeed();
            RssChannel channel = new RssChannel();
            //set Rss channel properties
            ArrayList items=DataController.ItemController.create().getSortedItems(20);
            foreach (Common.DataObject.Item itemObj in items)
            {
                
                string title = ((Common.DataObject.BibTexStruct)(itemObj.BibTexes[0])).value; 
                string author=((Common.DataObject.BibTexStruct )(itemObj.BibTexes[1])).value;
                //set new item properties
                RssItem rssItem = new RssItem();
                rssItem.Title = "New paper added to the library: Title-" + title;
                rssItem.Link = new Uri("http://www.google.com");               
                rssItem.Description = "It is published by " + author +" belong to category " + itemObj.Category;
                //DateTime now = new DateTime();
                //now = DateTime.Now;
                rssItem.PubDate =itemObj.DateAdded;
                RssGuid Guid = new RssGuid();
                Guid.Name = itemObj.Id;
                rssItem.Guid = Guid;
                channel.Items.Add(rssItem);
                channel.Title = "Newest additions in my library";
                channel.Description = "New Item";
                channel.Link = new Uri("http://www.google.com");
                channel.LastBuildDate =rssItem.PubDate;              
            }
         
            return channel;
        }
       
   
        
    }
}
